<template>
  <div>
    <div class="newarticle">
      <h4 class="title">{{ newinfo.title }}</h4>
      <p class="subtile">
        <span>发布时间：{{ newinfo.add_time | dataFormat }}</span>
        <span>点击次数：{{ newinfo.click }}次</span>
      </p>
      <hr>
      <div class="content" v-html="newinfo.content">

      </div>

      <!-- 评论子组件区域  -->
      <comment-box></comment-box>
    </div>

  </div>
</template>

<script>
  // 引入评论子组件
  import comment from "../../subcompontents/comment.vue"
  export default {
    data() {
      return {
        // 获取路径上面的id   //  get是用query
        id: this.$route.params.id,
        newinfo: {},
      }
    },
    created() {
      this.getNewsinfo();
    },
    methods: {
      getNewsinfo() {
        this.$http.get('api/getnew/' + this.id).then(result => {
          if (result.body.status === 0) {
            this.newinfo = result.body.message[0];
          } else {
            Toast('获取数据失败')
          }
        });
      },
    },
    components: {
      "comment-box":comment
    }
  }
</script>
<style lang="scss" scped>
  .newarticle {
    padding: 0 5px;

    .title {
      font-size: 16px;
      text-align: center;
      margin: 15px 0;
      color: red
    }

    .subtitle {
      display: flex;
      justify-content: space-between;
      padding-bottom: 5px;
    }

    .content {
      color: #666;
      line-height: 1.8;
      font-size: 14px
    }
  }
</style>